/*
day62_2
2019.10.29
*/
#include<queue>
using namespace std;

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
};


class Solution {
public:
    vector<double> averageOfLevels(TreeNode* root) 
	{
        queue<struct TreeNode *> q;
        q.push(root);
        struct TreeNode *cur;
        vector<double> vec;
        while( !q.empty() )
        {
        	int size = q.size();
        	double sum=0;
        	for(int i=0;i<size;i++)
        	{
        		cur=q.front();
        		q.pop();
        		sum += cur->val;
        		
        		if(cur->left)	q.push(cur->left);
        		if(cur->right)	q.push(cur->right);
			}
			sum /=size;
			vec.push_back(sum);
		}
		return vec;
    }
};


int main()
{
	return 0;
}
